home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Color Picker SDK / Sample Code / ScrapPicker Sample / Sources ƒ / PickerCommon.h next >
Encoding:
Text File  |  1997-06-13  |  3.5 KB  |  118 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        PickerCommon.h
  3.     Copyright:    © 1996-1997 by Apple Computer, Inc., all rights reserved.
  4. */
  5.  
  6.  
  7. //===============================================================================
  8. //
  9. //                                  PickerCommon.h
  10. //
  11. //===============================================================================
  12.  
  13.  
  14. #pragma once
  15.  
  16.  
  17. #include <QDOffscreen.h>
  18. #include <Sound.h>
  19.  
  20.  
  21. #if GENERATINGPOWERPC
  22.  
  23.     #if USE_COMPONENT_PROC_INFO
  24.     
  25.         #define    CallComponentFunctionWithStorageUniv(storage, params, funcName)                    \
  26.             CallComponentFunctionWithStorageProcInfo(storage, params, (ProcPtr)do##funcName,    \
  27.                                                      upp##funcName##ProcInfo)
  28.     
  29.     #else            // !USE_COMPONENT_PROC_INFO
  30.     
  31.         #define    CallComponentFunctionWithStorageUniv(storage, params, funcName)                    \
  32.             CallComponentFunctionWithStorage(storage, params, &funcName##RD)
  33.     
  34.     #endif            // USE_COMPONENT_PROC_INFO
  35.  
  36.     #define    CallComponentFunctionUniv(params, funcName)                                            \
  37.             CallComponentFunction(params, &funcName##RD)
  38.     #define    INSTANTIATE_ROUTINE_DESCRIPTOR(funcName)                                             \
  39.             RoutineDescriptor funcName##RD =                                                    \
  40.             BUILD_ROUTINE_DESCRIPTOR (upp##funcName##ProcInfo, do##funcName)
  41.  
  42. #else                 // !GENERATINGPOWERPC
  43.  
  44.     #define    CallComponentFunctionWithStorageUniv(storage, params, funcName)                        \
  45.             CallComponentFunctionWithStorage(storage, params, (ComponentFunctionUPP)do##funcName)
  46.     #define    CallComponentFunctionUniv(params, funcName)                                            \
  47.             CallComponentFunction(params, (ComponentFunctionUPP)do##funcName)
  48.  
  49. #endif                // GENERATINGPOWERPC
  50.  
  51.  
  52. #define    kUpArrow                0x1E    // Key ID's
  53. #define    kDnArrow                0x1F
  54. #define    kLtArrow                0x1C
  55. #define    kRtArrow                0x1D
  56. #define    kReturn                    0x0D
  57. #define    kEnter                    0x03
  58. #define    kTab                    0x09
  59. #define    kBackSpace                0x08
  60.  
  61.  
  62.                 // Handy color-swapping macros.
  63. #define PMCOLOR2RGBCOLOR(pmColor, rgbColor)                                        \
  64.         rgbColor.red = pmColor.color.rgb.red;                                    \
  65.         rgbColor.green = pmColor.color.rgb.green;                                \
  66.         rgbColor.blue = pmColor.color.rgb.blue;
  67.  
  68. #define RGBCOLOR2PMCOLOR(rgbColor, pmColor)                                        \
  69.         pmColor.color.rgb.red = rgbColor.red;                                    \
  70.         pmColor.color.rgb.green = rgbColor.green;                                \
  71.         pmColor.color.rgb.blue = rgbColor.blue;
  72.  
  73. #define RGBCOLOREQUALSRGBCOLOR(rgbColorA, rgbColorB)                            \
  74.         ((rgbColorA.red == rgbColorB.red) &&                                     \
  75.         (rgbColorA.green == rgbColorB.green) &&                                 \
  76.         (rgbColorA.blue == rgbColorB.blue))
  77.  
  78. #define HSLCOLOREQUALSHSLCOLOR(hslColorA, hslColorB)                            \
  79.         ((hslColorA.hue == hslColorB.hue) &&                                     \
  80.         (hslColorA.saturation == hslColorB.saturation) &&                         \
  81.         (hslColorA.lightness == hslColorB.lightness))
  82.  
  83.  
  84.                 // Exception handling macros
  85. #define require(assertion, exception)                                      \
  86.     do {                                                                \
  87.         if (assertion) ;                                                \
  88.         else {                                                            \
  89.             goto exception;                                                \
  90.         }                                                                \
  91.     } while (false)
  92.  
  93. #define require_action(assertion, exception, action)                 \
  94.     do {                                                            \
  95.         if (assertion) ;                                            \
  96.         else {                                                        \
  97.             { action }                                                \
  98.             goto exception;                                            \
  99.         }                                                            \
  100.     } while (false)
  101.  
  102. #define check(assertion)
  103.  
  104.  
  105.             // PickerCommonDraw.c
  106. void    DropRectShadow                    (Rect *, SInt16, Boolean);
  107. void    SetPatternToColor                (PixPatHandle pat, RGBColor *rgb, Boolean hasColor);
  108. void    GetGrayPattern                    (unsigned short, Pattern *);
  109.  
  110.             // PickerCommonUtils.c
  111. void    PasStringCopy                    (StringPtr, StringPtr);
  112. Handle    HappiNewHandle                    (Size, OSErr *);
  113. Handle    HappiNewHandleClear                (Size, OSErr *);
  114. Ptr        HappiNewPointer                    (Size, OSErr *);
  115. Ptr        HappiNewPointerClear            (Size, OSErr *);
  116. Handle    HappiGetResource                (ResType, SInt16, OSErr *);
  117.  
  118.